<template>
  <a-row :gutter="5">
    <a-card style="position: relative">
      <div class="table-page-search-wrapper">
        <a-form layout="inline" @keyup.enter.native="searchQuery">
          <a-row :gutter="24">
            <a-col :md="6" :sm="8">
              <a-form-item label="模型名称">
                <a-input placeholder="请输入模型名称" v-model="queryParam.modelName"></a-input>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="8">
              <a-form-item label="状态">
                <j-dict-select-tag v-model="queryParam.status" placeholder="请选择状态" dict-code="model_approve_status" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="8">
              <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">清除条件</a-button>
              </span>
            </a-col>
          </a-row>
        </a-form>
      </div>
      <!-- table区域-begin -->
      <div>
        <a-table ref="table" size="middle" bordered rowKey="id" :columns="columns" :dataSource="dataSource"
          :pagination="ipagination" :loading="loading" @change="handleTableChange">
          <span slot="action" slot-scope="text, record">
            <span>
              <a @click="handleCheck(record, '查看')">查看</a>
            </span>
            <span v-if="record.status == 1">
              <a-divider type="vertical" />
              <a @click="handleApprove(record, 1)">通过</a>
              <a-divider type="vertical" />
              <a @click="goBack(record)">驳回</a>
            </span>
          </span>
        </a-table>
      </div>
      <!-- table区域-end -->
      <CheckAndEditModel ref="modalForm" @ok="modalFormOk"></CheckAndEditModel>


      <j-modal title="驳回" :width="600" :visible="visible" :maskClosable="false" @close="close" cancelText="关闭">
        <a-form-model>
          <a-form-model-item label="备注" prop="remarks">
            <a-textarea v-model="remarks"></a-textarea>
          </a-form-model-item>
        </a-form-model>
      </j-modal>
    </a-card>
  </a-row>
</template>
<script>
// 表头
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import CheckAndEditModel from './CheckAndEditModel'
import columns from './indexColumns'
import { getAction, postAction, putAction, deleteAction } from '@/api/manage'

export default {
  name: '审计案例管理',
  mixins: [JeecgListMixin],
  components: {
    CheckAndEditModel,
  },
  data() {
    return {
      visible: false,
      remarks: '',
      queryParam: {},
      // 表头
      columns: columns(this),
      url: {
        list: '/sjmx2/modelTemplateApprove/list',
        approve: '/sjmx2/modelTemplateApprove/approve',
      },
    }
  },
  methods: {
    handleCheck(e) {
      this.$router.push('/zdypzbb?id=' + e.modelId + '&check=true');
    },
    goBack(record) {
      this.record = record
      this.visible = true
    },
    close(isSubmit) {
      if (isSubmit) {
        this.handleApprove(this.record, 2)
      } else {
        this.visible = false
        this.remarks = ""
      }
    },
    handleApprove(record, status) {
      let { id } = record
      let remark = this.remarks
      getAction(this.url.approve, { approveId: id, status: status, remark: remark }).then((res) => {
        if (res.code == 200) {
          this.$message.success('操作成功')
          this.visible = false
          this.remarks = ""
          this.loadData();
        }
      })
    },
  },
  created() {
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less'
</style>
<style lang="less" scoped>
.ant-row {
  height: 100%;

  .ant-col {
    height: 100%;

    .ant-card {
      height: 100%;

      /deep/ .ant-card-body {
        padding: 15px;
      }
    }
  }
}
</style>